<?php
global $Config;
require_once($Config->WebCMSRoot.'Base/View.php');

Class HeaderView extends BaseView
{
	var $__NEWLINE;
	
	function HeaderView()
	{
		parent::BaseView();
		
		$this->__NEWLINE = "\n";
	}
	
	function ShowHeader($header)
	{
//print('<pre>'.var_export($header, true).'</pre>');exit;
//print('<pre>'.var_export($this, true).'</pre>');exit;
		$this->output = '<head>' . $this->__NEWLINE;
		
		// Title;
		if ($header->Title != '')
		{
			$this->output .= '<title>' . $header->Title . '</title>' . $this->__NEWLINE;
			$this->output .= '<meta name="title" content="' . $header->Title . '" />' . $this->__NEWLINE;
		}
		
		// Favicon;
		if ($header->Favicon != '')
		{
			$this->output .= '<link rel="shortcut icon" href="' . $header->Favicon . '" />' . $this->__NEWLINE;
		}
		
		// Stylesheet;
		foreach ($header->Stylesheet as $key=>$val)
		{
			$this->output .= '<link href="' . $val . '" rel="stylesheet" type="text/css" />' . $this->__NEWLINE;
		}
		
		// Style;
		if ($header->Style != '')
		{
			$this->output .= '<style type="text/css">' . $header->Style . '</style>' . $this->__NEWLINE;
		}
		
		// Javascript;
		if ($header->Javascript != '')
		{
			$this->output .= '<script language="javascript" type="text/javascript">' . $header->Javascript . '</script>';
			$this->output .= '</script>' . $this->__NEWLINE;
		}
		
		// JavascriptFile;
		foreach ($header->JavascriptFile as $key=>$val)
		{
			$this->output .= '<script language="javascript" type="text/javascript" src="' . $val . '"></script>' . $this->__NEWLINE;
		}
		
		// HttpEquiv;
		foreach ($header->HttpEquiv as $key=>$val)
		{
			$arr = split('\|', $val);
			$this->output .= '<meta http-equiv="' . $arr[0] . '" content="' . $arr[1] . '" />' . $this->__NEWLINE;
		}
		
		// Meta;
		foreach ($header->Meta as $key=>$val)
		{
			$arr = split('\|', $val);
			$this->output .= '<meta name="' . $arr[0] . '" content="' . $arr[1] . '" />' . $this->__NEWLINE;
		}
		
		// Conditional Statements;
		foreach ($header->Conditional as $key=>$val)
		{
			$arr = split('\|', $val);
			$this->output .= '<!--[if ' . $arr[0] . ']>' . $this->__NEWLINE;
			$this->output .= html_entity_decode($arr[1]) . $this->__NEWLINE;
			$this->output .= '<![endif]-->' . $this->__NEWLINE;
		}
		
		$this->output .= '</head>' . $this->__NEWLINE;
	}
}
?>